package cn.chenfeifx.core.controls;

import cn.chenfeifx.core.controls.skins.CFRadioButtonSkin;
import cn.chenfeifx.core.common.ResourcesLoader;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;

public class CFRadioButton extends RadioButton {

    private static final String STYLE_SHEET = ResourcesLoader.load("/cn/chenfeifx/core/css/cf-radio-button.css");
    private static final String STYLE_CLASS = "cf-radio-button";

    public CFRadioButton() {
        initialize();
    }

    public CFRadioButton(String text) {
        this();
        setText(text);
    }

    public CFRadioButton(String text, boolean selected, ToggleGroup toggleGroup) {
        this(text, toggleGroup);
        setSelected(selected);
    }

    public CFRadioButton(String text, ToggleGroup toggleGroup) {
        this(text);
        setToggleGroup(toggleGroup);
        initialize();
    }

    private void initialize() {
        setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
        getStyleClass().add(STYLE_CLASS);
    }

    @Override
    protected CFRadioButtonSkin createDefaultSkin() {
        return new CFRadioButtonSkin(this);
    }

    @Override
    public String getUserAgentStylesheet() {
        return STYLE_SHEET;
    }
}
